//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package nc.pubimpl.ia.pfxx;

import nc.bs.pfxx.ISwapContext;
import nc.bs.pfxx.plugin.AbstractPfxxPlugin;
import nc.vo.pfxx.auxiliary.AggxsysregisterVO;
import nc.vo.pfxx.util.PfxxPluginUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;
import nc.vo.pubapp.pattern.model.entity.bill.IBill;
import nc.vo.pubapp.pattern.pub.Constructor;
import nc.vo.pubapp.pattern.pub.PubAppTool;

public abstract class AbstractIAPfxxPlugin<E extends IBill> extends AbstractPfxxPlugin {
    public AbstractIAPfxxPlugin() {
    }

    protected abstract E[] insert(E[] var1);

    protected final Object processBill(Object vo, ISwapContext swapContext, AggxsysregisterVO aggxsysvo) throws BusinessException {
        E resvo = (E)(vo);
        String id = PfxxPluginUtils.queryBillPKBeforeSaveOrUpdate(swapContext.getBilltype(), swapContext.getDocID());
        E returnVO = null;
        E[] bills = (E[])(Constructor.declareArray(resvo.getClass(), 1));
        bills[0] = resvo;
        String pk = "";
        try {
            if (PubAppTool.isNull(id)) {
                returnVO = this.insert(bills)[0];
                pk = returnVO.getPrimaryKey();
                // 新增对应的id重复推送时走修改
                PfxxPluginUtils.addDocIDVsPKContrast(swapContext.getBilltype(), swapContext.getDocID(), returnVO .getPrimaryKey());
            } else {
                pk = id;
//                returnVO = this.update(bills)[0];
            }
        } catch (Exception ex) {
            ExceptionUtils.wrappException(ex);
            return null;
        }
        // modify by wy at 20250814  弃用标准产品无脑新增
//        PfxxPluginUtils.addDocIDVsPKContrast(swapContext.getBilltype(), swapContext.getDocID(), id);
        return pk;
    }

    protected abstract E[] update(E[] var1);
}
